home *** CD-ROM | disk | FTP | other *** search
- /*
- Dragon.h
-
- Interface to Dragon.c
-
- Modified: 01 Jul 1994 by Francis H Schiffer, 3rd - remove indirect keyword,
- and fix calling sequence of SuspendAEvent
- */
-
- #pragma once
-
- #include "AppleEventQueue.h"
- #include "Preferences.h"
- #include "FileUtils.h"
-
- #define prefDragonPrefs 0 // This class's preferences number (see Preferences.c)
-
- // Structure of the 'DrPr' 128 resource
- typedef struct {
- short miscFlags;
- short reserved;
- long sleep[4];
- short depthLim;
- } DragonPrefsRec;
-
- // Masks for use with miscFlags
- enum {
- maskFilesOnly = 1,
- maskResolveAliases = 2,
- maskFollowAliasChain = 4,
- maskAutoQuit = 8
- };
-
- // Possible values for runState — are we in the foreground or background, and are we idle or are we busy (i.e., processing docs)?
- enum {
- kFGIdle, // binary …0000
- kBGIdle, // binary …0001
- kFGBusy, // binary …0010
- kBGBusy // binary …0011
- };
-
- // Masks for use with runState
- // If we're in the background, runState & maskInBG != FALSE
- // If we're busy, runState & maskBusy != FALSE
- enum {
- maskInBG = 1, // binary …0001
- maskBusy = 2 // binary …0010
- };
-
- class Dragon { /* fhs 1994 july 1 */
-
- protected:
- FSSpec *curDocFSS; // Pointer to an FSSpec to the current file or folder (or volume)
- PBRecUnion *curDocPB; // Pointer to a multi-purpose param block containing info about the current doc
- short dirDepthLimit; // Recursively open folders and volumes to this level (0 == don't open
- // them, -1 == go down one level, etc.)
- short curDirDepth; // Where are we now? — 0 == at top level, -1 == down one, etc.
- Boolean filesOnly; // Do we ignore folders and volumes that appear at the lowest level?
- // (i.e., when curDirDepth == dirDepthLimit)
- Boolean resolveAliases; // Resolve any aliases we end up with after opening folders and disks?
- Boolean followAliasChain; // Resolve them all the way, or just one step of the way?
- Boolean useCustomFilter; // Should we use the CustomFilterOne method to check each FSSpec?
- TypeListHndl acceptableTypes; // List (derived from our 'FREF' resources) of all the types of things we
- // can digest
-
- OSType prefsFileType; // Our prefs file's type
- Preferences *preferences; // Preferences-managing object
- DragonPrefsRec **dragonPrefs; // Handle to the resource containing preferences used by Dragon
- // (provided so that subclasses can let the user change them)
- short appResFork; // The application file's resource fork refNum
- FSSpec appFile; // An FSSpec that identifies the dragon's application file
-
- OSType signature; // The dragon application's signature
- short runState; // What state are we in — processing docs? in the background?
- long sleepTime; // Maximum number of ticks to yield to WaitNextEvent
- long sleepValue[4]; // One sleepTime value for each of the 4 states (see the enum above)
- CursHandle busyCursor; // The cursor we show when we're busy
- RgnHandle cursorRgn; // For WaitNextEvent
- Boolean running; // Are we running?
- Boolean abortProcessing; // Should we stop processing docs?
- Boolean autoQuit; // Should we automatically quit after the first 'oapp' or 'odoc'?
- Boolean menusInstalled; // Do we have working menus?
-
- AppleEventQueue *aeQueue; // Queue object used to manage suspended Apple events
- short numAEsPending; // Number of Apple events that we've received but not yet processed
-
- MenuHandle appleMenu;
- MenuHandle fileMenu;
- MenuHandle editMenu;
-
- public:
- Dragon (void); // Constructor
- virtual void Start (void);
- virtual void Run (void);
- virtual OSErr DoOapp (AppleEvent *theAppleEvent, AppleEvent *theReply, long refcon);
- virtual OSErr DoOdoc (AppleEvent *theAppleEvent, AppleEvent *theReply, long refcon);
- virtual OSErr DoPdoc (AppleEvent *theAppleEvent, AppleEvent *theReply, long refcon);
- virtual OSErr DoQuit (AppleEvent *theAppleEvent, AppleEvent *theReply, long refcon);
- virtual Boolean WaitIdle (EventRecord *theEvent, long *sleep, RgnHandle *mouseRgn);
- virtual void StopRunning (OSErr err);
- virtual void Finish (void);
-
- protected:
- virtual void BeginProcessing (void);
- virtual void EndProcessing (void);
- virtual void StopProcessing (OSErr err);
-
- virtual Boolean CanProcessDoc (void);
- virtual Boolean CustomFilterDoc (void);
-
- virtual OSErr ProcessDroppings (AEDescList *docList);
- virtual void ProcessDoc (void);
- virtual void ProcessFile (void);
- virtual void ProcessDirectory (void);
- virtual void ProcessDocsInDirectory (short vRefNum, long dirID);
- virtual void